package com.ljy.my_study.java.juc.condition;

/**
 * @author lijunying
 * @date 2021/2/1 11:00
 */
public class TestMain {

    public static void main(String[] args) throws InterruptedException {
        TestQueue<Integer> queue=new TestQueue<>();
        int count=10;
        Thread[] threads=new Thread[count];
        for(int i=0;i<count;i++){
            int num=i;
            threads[i]=new Thread(()->{
                if(num>=5){
                    queue.put(num);
                }else{
                    System.out.println(queue.take());
                }
            });
        }
        for(int i=0;i<count;i++){
            if(i==5){
//                Thread.sleep(1L);
            }
            threads[i].start();
        }
    }
}
